package dyyx.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;

public class HttpServerInit extends ChannelInitializer<SocketChannel> {

	/*
	private final SslContext sslCtx;

    public ServerInitializer(SslContext sslCtx) {
        this.sslCtx = sslCtx;
    }
    */

    @Override
    public void initChannel(SocketChannel ch) {
    	System.out.println("\n*********initChannel run,"+ch+"\n\n");
    	
        ChannelPipeline p = ch.pipeline();
        
        /*
        if (sslCtx != null) {
            p.addLast(sslCtx.newHandler(ch.alloc()));
        }
        */
        // HTTP 服务的解码器
        p.addLast(new HttpServerCodec());
        // HTTP 消息的合并处理
        
        p.addLast(new HttpObjectAggregator(2048)); 
        // p.addLast(new HttpServerHandler());  
        p.addLast(new HttpServerHandler2());
        //  注意 HttpServerHandler 与 HttpServerHandler2 区别
    }
    
    
    
    
	

	
}
